$(function () {

    var allocation_datagrid = $("#allocation_datagrid");

    allocation_datagrid.datagrid({
        url:"productstockallocation/list",
        pagination:true,
        fit:true,
        fitCloumns:true,
        singleSelect:true,
        columns:[[
            {field:"product",title:"商品名称",width:100,formatter:formatterProductName},
            {field:"intoShop",title:"调入仓库",width:100,formatter:formatterDepot},
            {field:"outShop",title:"调出仓库",width:100,formatter:formatterDepot},
            {field:"outNumber",title:"调出数量",width:100},
            {field:"outShopOriginNumber",title:"调出仓库原有数量",width:100},
            {field:"outShopNowNumber",title:"调出店铺现有数量",width:100},
            {field:"intoShopOriginNumber",title:"调入店铺原有数量",width:100},
            {field:"intoShopNowNumber",title:"调入吊牌现有数量",width:100,},
        ]],
        toolbar:"#allocation_datagrid_toolbar",
        onLoadSuccess:function (data) {
            console.log(data);
        }
    })

    cmdObj = {
        allocation_search:function () {
            var keyword = $("#allocation_search").val();
            allocation_datagrid.datagrid("load",{keyword:keyword});
        },
        reload:function () {
            allocation_datagrid.datagrid("reload");
        }
    }

    $("a[data-cmd]").click(function () {
        var cmd =$(this).data("cmd");
        cmdObj[cmd]();
    })


})

function formatterProductName(value,row,index) {
    return value ? value.productName :"";
}
function formatterDepot(value,row,index) {
    return value ? value.name :"";
}